﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Deflection
{
    class Score
    {
        public int ProjectilesFired { get; set; }
        public int Multiplyer { get; set; }
        private long IndividualScore { get; set; }
        public Vector2 position;
        public Color color;

        private int maxMultiplyer = 0;
        public int MaxMultipler
        {
            get { return maxMultiplyer; }
            set
            {
                if (value > maxMultiplyer)
                {
                    maxMultiplyer = value;
                }
            }
        }


       /* private long longestLife = 0;
        public long LongestLife
        {
            get { return longestLife; }
            set
            {
                if (value > longestLife)
                {
                    longestLife = value;
                }

                TotalLife += value;
            }
        }

        private long totalLife = 0;
        public long TotalLife
        {
            get { return totalLife; }
            set { totalLife = value; }
        }

        public string TotalLifeFormated
        {
            get { return FormatLife(totalLife); }
        }

        public string LongestLifeFormated
        {
            get { return FormatLife(longestLife / 60); }
        }


        private string FormatLife(long life)
        {
            TimeSpan time = TimeSpan.FromSeconds(life);

            return string.Format("{0:D2}h:{1:D2}m:{2:D2}s",
                                time.Hours,
                                time.Minutes,
                                time.Seconds);
        }*/



       // Add enemy stats
        
        public Score(Vector2 position, Color color)
        {
            this.position = position;
            this.color = color;
            Multiplyer = 1;
        }

        /// <summary>
        /// Used to add a score to the player, will apply the current multiplyer
        /// </summary>
        /// <param name="score"></param>
        public void AddScore(long score)
        {
            IndividualScore += (score * Multiplyer);
        }

        /// <summary>
        /// Use when ever a player kills an enemy, will give them the required score and stats
        /// </summary>
        /// <param name="type">The type of enemy that was killed</param>
        public void AddEnemyDeath(Enemy.EnemyType type)
        {
            switch (type)
            {
                case Enemy.EnemyType.SquareEnemy:
                    AddScore((int)Enemy.EnemyScore.SquareEnemy);
                    break;
                case Enemy.EnemyType.TriangleEnemy:
                    AddScore((int)Enemy.EnemyScore.TriangleEnemy);
                    break;
                case Enemy.EnemyType.HexagonEnemy:
                    AddScore((int)Enemy.EnemyScore.HexagonEnemy);
                    break;
                case Enemy.EnemyType.SuperSquare:
                    AddScore((int)Enemy.EnemyScore.SuperSquare);
                    break;
                case Enemy.EnemyType.SuperTriangle:
                    AddScore((int)Enemy.EnemyScore.SuperTriangle);
                    break;
                case Enemy.EnemyType.SuperHexagon:
                    AddScore((int)Enemy.EnemyScore.SuperHexagon);
                    break;
            }

        }

        public void Draw(SpriteBatch spriteBatch)
        {
            Vector2 textSize = GameParameters.GAME_FONT.MeasureString(IndividualScore.ToString());
            spriteBatch.DrawString(GameParameters.GAME_FONT, IndividualScore.ToString(), position, color, 0f, textSize, 0.45f, SpriteEffects.None, 0f);
        }
    }
}
